package com.lekang.le.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.lekang.common.annotation.Log;
import com.lekang.common.core.controller.BaseController;
import com.lekang.common.core.domain.AjaxResult;
import com.lekang.common.enums.BusinessType;
import com.lekang.le.domain.AccraditationRecord;
import com.lekang.le.service.IAccraditationRecordService;
import com.lekang.common.utils.poi.ExcelUtil;
import com.lekang.common.core.page.TableDataInfo;

/**
 * 审批记录Controller
 * 
 * @author szh
 * @date 2025-10-20
 */
@RestController
@RequestMapping("/le/accraditationRecord")
public class AccraditationRecordController extends BaseController
{
    @Autowired
    private IAccraditationRecordService accraditationRecordService;

    /**
     * 查询审批记录列表
     */
    @PreAuthorize("@ss.hasPermi('le:accraditationRecord:list')")
    @GetMapping("/list")
    public TableDataInfo list(AccraditationRecord accraditationRecord)
    {
        System.out.println("调用listController");
        startPage();
        List<AccraditationRecord> list = accraditationRecordService.selectAccraditationRecordList(accraditationRecord);
        return getDataTable(list);
    }

    /**
     * 导出审批记录列表
     */
    @PreAuthorize("@ss.hasPermi('le:accraditationRecord:export')")
    @Log(title = "审批记录", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, AccraditationRecord accraditationRecord)
    {
        List<AccraditationRecord> list = accraditationRecordService.selectAccraditationRecordList(accraditationRecord);
        ExcelUtil<AccraditationRecord> util = new ExcelUtil<AccraditationRecord>(AccraditationRecord.class);
        util.exportExcel(response, list, "审批记录数据");
    }

    /**
     * 获取审批记录详细信息
     */
    @PreAuthorize("@ss.hasPermi('le:accraditationRecord:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(accraditationRecordService.selectAccraditationRecordById(id));
    }
    @PreAuthorize("@ss.hasPermi('le:accraditationRecord:query')")
    @GetMapping(value = "/byBussniessId/{bussniessId}")
    public AjaxResult byBussniessId(@PathVariable("bussniessId") Long bussniessId)
    {
        return success(accraditationRecordService.selectAccraditationRecordByBussniessIdSZH(bussniessId));
    }

    /**
     * 新增审批记录
     */
    @PreAuthorize("@ss.hasPermi('le:accraditationRecord:add')")
    @Log(title = "审批记录", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody AccraditationRecord accraditationRecord)
    {
        return toAjax(accraditationRecordService.insertAccraditationRecord(accraditationRecord));
    }
    /**
     * 退住新增审批记录
     */
    @PreAuthorize("@ss.hasPermi('le:accraditationRecord:add')")
    @Log(title = "审批记录", businessType = BusinessType.INSERT)
    @PostMapping("tuizhuadd")
    public AjaxResult tuizhuadd(@RequestBody AccraditationRecord accraditationRecord)
    {
        return toAjax(accraditationRecordService.tuizhuinsertAccraditationRecord(accraditationRecord));
    }
    @PreAuthorize("@ss.hasPermi('le:accraditationRecord:add')")
    @Log(title = "审批记录", businessType = BusinessType.INSERT)
    @PostMapping("/addSZH")
    public AjaxResult addSZH(@RequestBody AccraditationRecord accraditationRecord)
    {
        return toAjax(accraditationRecordService.insertAccraditationRecordSZH(accraditationRecord));
    }

    /**
     * 修改审批记录
     */
    @PreAuthorize("@ss.hasPermi('le:accraditationRecord:edit')")
    @Log(title = "审批记录", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody AccraditationRecord accraditationRecord)
    {
        return toAjax(accraditationRecordService.updateAccraditationRecord(accraditationRecord));
    }

    /**
     * 删除审批记录
     */
    @PreAuthorize("@ss.hasPermi('le:accraditationRecord:remove')")
    @Log(title = "审批记录", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(accraditationRecordService.deleteAccraditationRecordByIds(ids));
    }
}
